package cn.edu.lcu.cs.designpattern.composite.safety;

public class Client {
    public static void main(String[] args) {
        Branch root = new Branch();
        root.setValue("根结点");
        root.doSomething();

        Branch branch = new Branch();
        branch.setValue("分枝结点1");
        branch.add(new Leaf("叶子结点11"));
        branch.add(new Leaf("叶子结点12"));
        branch.add(new Leaf("叶子结点13"));
        root.add(branch);

        Branch branch2 = new Branch();
        branch2.setValue("分枝结点2");
        branch2.add(new Leaf("叶子结点21"));
        branch2.add(new Leaf("叶子结点22"));
        branch2.add(new Leaf("叶子结点23"));
        root.add(branch2);
        root.traversal(); // 遍历这棵树
    }
}
